﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Core.Controls;
using Core.Interfaces.IPresenters;

namespace Core.Views
{
    public partial class CustomerView : Form,ICustomerView 
    {

        private ICustomerControl _customerControl;
        public CustomerView()
        {
            InitializeComponent();
            _customerControl = privatPersonControll2;
        }

        public BindingSource Customer
        {
            get { return iCustomerBindingSource; }
            set { iCustomerBindingSource = value; }
        }

        public BindingSource AdditionalModel
        {
            get { return _customerControl.AdditionalModel; }
            set { _customerControl.AdditionalModel = value; }
        }


        public event EventHandler SaveCustomer;

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {
            groupBox2.Controls.Clear();
            if (radioButton1.Checked)
            {
              
                var c = new PrivatPersonControll {Dock = DockStyle.Fill};
                _customerControl = c;
                groupBox2.Controls.Add(c);
                ToPrivatePirson(this, null);
            }
            else
            {
                var c = new JurajialPersonControll() {Dock = DockStyle.Fill};
                _customerControl = c;
                groupBox2.Controls.Add(c);
                ToJurajialPerson(this, null);
            }
        }


        private void button1_Click(object sender, EventArgs e)
        {
            if (SaveCustomer != null)
            {
                SaveCustomer(this, null);
            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        public EventHandler ToPrivatePirson;
        public EventHandler ToJurajialPerson;
    }
}
